using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace MageDefender.GameClasses
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class AnimatedGameModel : Node
    {
        Graphics.DBAnimatedModel theModel;

        public Graphics.DBAnimatedModel TheModel
        {
            get { return theModel; }
            set { theModel = value; }
        }

        public AnimatedGameModel(Game game)
            : base(game)
        {

            theModel = new Graphics.DBAnimatedModel(game);
            
            // TODO: Construct any child components here
        }

        public void SetFileProperties(string n, string t, string nm)
        {
            theModel.Name = n;
            theModel.TextureColor = t;
            theModel.TextureNormal = nm;
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            
            base.Initialize();
        }

        public void Initialize(string n, string tC, string tN, Matrix projMatrix, Matrix viewMatrix)
        {
            theModel.Name = n;
            theModel.TextureColor = tC;
            theModel.TextureNormal = tN;
            theModel.Initialize(projMatrix, viewMatrix);

            Initialize();
        }

        public void Initialize(Matrix projMatrix, Matrix viewMatrix)
        {
            theModel.Initialize(projMatrix, viewMatrix);

            Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }

        public void Update(Vector3 vecEye, Matrix viewMatrix, Matrix renderMatrix, GameTime gameTime, TimeSpan timeSpan)
        {
            theModel.Update(new Vector4(vecEye, 0), viewMatrix, renderMatrix, gameTime, timeSpan);
        }

        public override void Draw(GameTime gameTime)
        {
            theModel.Draw(gameTime);

            base.Draw(gameTime);
        }
    }
}